<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />

    <title>插件开发</title>
    <meta name="description" content="  插件开发          简介      快速开始      注：此处为镜像文档，最新在线文档请看：http://xmake.io/#/zh/plugins插件开发简介XMake完全支持插件模式，我们可以很方便的扩展实现自己的插件，并且xmake也提供了一些内建的使用插件。我们可以执行下 xmake -h ...">

    
    <meta name="keywords" content="xmake,文档,插件,tboox" /> 

    <!-- qq oauth -->
    <meta property="qc:admins" content="5211601217706727767255" />

    <!--icon -->
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" sizes="192x192" href="/static/img/nice-highres.png" />
	<link rel="apple-touch-icon-precomposed" href="/static/img/apple-touch-icon-57x57-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/apple-touch-icon-72x72-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/img/apple-touch-icon-114x114-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/img/apple-touch-icon-144x144-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="180x180" href="/static/img/retinahd_icon.png" />
	<meta name="msapplication-TileImage" content="/static/img/retinahd_icon.png" />
	
    <link rel="stylesheet" href=" /css/fontawesome/css/font-awesome.min.css ">
    <link rel="stylesheet" href=" /css/main.css ">
    <link rel="canonical" href="https://tboox.org/cn/docs/xmake/plugins/">
    <link rel="alternate" type="application/rss+xml" title="TBOOX Open Source Project" href="https://tboox.org/feed.xml ">
    <link rel="alternate" hreflang="en" href="https://tboox.org/" />
    <link rel="alternate" hreflang="zh-Hans" href="https://tboox.org/cn/" />

    <!-- css -->
    <link href="/css/reward.css" rel="stylesheet" type="text/css"> 




    <script type="text/javascript">
    function isPC(){    
        var userAgentInfo = navigator.userAgent;  
        var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");    
        var flag = true;    
        for (var v = 0; v < Agents.length; v++) {    
            if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }    
        }    
        return flag;    
    }
    </script>

<!-- baidu ads -->



    <!-- baidu ads -->

</head>


  <body>

    <header id="top">
    <div class="wrapper">
        <a href="/cn" class="brand">TBOOX</a>
        <button id="headerMenu" class="menu"><i class="fa fa-bars"></i></button>
        <nav id="headerNav">
            <ul>
                <li>
                    
                    <a href="/?lang=0">
                    
                        <i class="fa fa-home"></i>English
                    </a>
                </li>

                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/project/">
                            
                        
                            <i class="fa fa-bookmark"></i>项目
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/archive/">
                            
                        
                            <i class="fa fa-archive"></i>归档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/category/">
                            
                        
                            <i class="fa fa-th-list"></i>分类
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/tag/">
                            
                        
                            <i class="fa fa-tags"></i>标记
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/docs/">
                            
                        
                            <i class="fa fa-book"></i>文档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="https://xmake.io/#/zh-cn/about/contact" target="_blank" >
                            
                        
                            <i class="fa fa-forumbee"></i>社区
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/donation/">
                            
                        
                            <i class="fa fa-heart"></i>捐助
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/about/">
                            
                        
                            <i class="fa fa-user"></i>关于
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            </ul>
        </nav>
    </div>
</header>



        <div class="page clearfix" post>
    <div class="left">
        <h1>插件开发</h1>
        <div class="label">

            <div class="label-card">
                <i class="fa fa-calendar"></i>2000-02-22
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
            


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#xmake" title="Category: xmake" rel="category">xmake</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


            </div>

            <div class="label-card">
            
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <!--a href="/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a-->
        <a href="/cn/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a>&nbsp;
    
        <!--a href="/tag/#%E6%96%87%E6%A1%A3" title="Tag: 文档" rel="tag">文档</a-->
        <a href="/cn/tag/#文档" title="Tag: 文档" rel="tag">文档</a>&nbsp;
    
        <!--a href="/tag/#%E6%8F%92%E4%BB%B6" title="Tag: 插件" rel="tag">插件</a-->
        <a href="/cn/tag/#插件" title="Tag: 插件" rel="tag">插件</a>
    
  

</span>

            </div>

        </div>
        <hr>
        <article itemscope itemtype="http://schema.org/BlogPosting">
        <ul id="markdown-toc">
  <li><a href="#插件开发" id="markdown-toc-插件开发">插件开发</a>    <ul>
      <li><a href="#简介" id="markdown-toc-简介">简介</a></li>
      <li><a href="#快速开始" id="markdown-toc-快速开始">快速开始</a></li>
      <li><a href="#运行插件" id="markdown-toc-运行插件">运行插件</a></li>
    </ul>
  </li>
  <li><a href="#内置插件" id="markdown-toc-内置插件">内置插件</a>    <ul>
      <li><a href="#宏记录和回放" id="markdown-toc-宏记录和回放">宏记录和回放</a>        <ul>
          <li><a href="#简介-1" id="markdown-toc-简介-1">简介</a></li>
          <li><a href="#记录操作" id="markdown-toc-记录操作">记录操作</a></li>
          <li><a href="#回放" id="markdown-toc-回放">回放</a></li>
          <li><a href="#命名宏" id="markdown-toc-命名宏">命名宏</a></li>
          <li><a href="#导入导出宏" id="markdown-toc-导入导出宏">导入导出宏</a></li>
          <li><a href="#列举显示宏" id="markdown-toc-列举显示宏">列举显示宏</a></li>
          <li><a href="#自定义宏脚本" id="markdown-toc-自定义宏脚本">自定义宏脚本</a></li>
          <li><a href="#内置的宏脚本" id="markdown-toc-内置的宏脚本">内置的宏脚本</a></li>
          <li><a href="#高级的宏脚本编写" id="markdown-toc-高级的宏脚本编写">高级的宏脚本编写</a></li>
        </ul>
      </li>
      <li><a href="#运行自定义lua脚本" id="markdown-toc-运行自定义lua脚本">运行自定义lua脚本</a>        <ul>
          <li><a href="#运行指定的脚本文件" id="markdown-toc-运行指定的脚本文件">运行指定的脚本文件</a></li>
          <li><a href="#运行内置的脚本命令" id="markdown-toc-运行内置的脚本命令">运行内置的脚本命令</a></li>
          <li><a href="#运行交互命令-repl" id="markdown-toc-运行交互命令-repl">运行交互命令 (REPL)</a></li>
        </ul>
      </li>
      <li><a href="#生成ide工程文件" id="markdown-toc-生成ide工程文件">生成IDE工程文件</a>        <ul>
          <li><a href="#简介-2" id="markdown-toc-简介-2">简介</a></li>
          <li><a href="#生成makefile" id="markdown-toc-生成makefile">生成Makefile</a></li>
          <li><a href="#生成compiler_commands" id="markdown-toc-生成compiler_commands">生成compiler_commands</a></li>
          <li><a href="#生成visualstudio工程" id="markdown-toc-生成visualstudio工程">生成VisualStudio工程</a></li>
        </ul>
      </li>
      <li><a href="#生成doxygen文档" id="markdown-toc-生成doxygen文档">生成doxygen文档</a></li>
    </ul>
  </li>
  <li><a href="#更多插件" id="markdown-toc-更多插件">更多插件</a>    <ul>
      <li><a href="#从app生成ipa包" id="markdown-toc-从app生成ipa包">从app生成ipa包</a></li>
    </ul>
  </li>
</ul>

<p>注：此处为镜像文档，最新在线文档请看：<a href="http://xmake.io/#/zh/plugins">http://xmake.io/#/zh/plugins</a></p>

<h2 id="插件开发">插件开发</h2>

<h4 id="简介">简介</h4>

<p>XMake完全支持插件模式，我们可以很方便的扩展实现自己的插件，并且xmake也提供了一些内建的使用插件。</p>

<p>我们可以执行下 <code class="highlighter-rouge">xmake -h</code> 看下当前支持的插件：</p>

<div class="highlighter-rouge"><pre class="highlight"><code>Plugins: 
    l, lua                                 Run the lua script.
    m, macro                               Run the given macro.
       doxygen                             Generate the doxygen document.
       hello                               Hello xmake!
       project                             Create the project file.
</code></pre>
</div>

<ul>
  <li>lua: 运行lua脚本的插件</li>
  <li>macro: 这个很实用，宏脚本插件，可以手动录制多条xmake命令并且回放，也可以通过脚本实现一些复杂的宏脚本，这个我们后续会更加详细的介绍</li>
  <li>doxygen：一键生成doxygen文档的插件</li>
  <li>hello: 插件demo，仅仅显示一句话：’hello xmake!’</li>
  <li>project： 生成工程文件的插件，目前仅支持(makefile)，后续还会支持(vs,xcode等工程)的生成</li>
</ul>

<h4 id="快速开始">快速开始</h4>

<p>接下来我们介绍下本文的重点，一个简单的hello xmake插件的开发，代码如下：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="c1">-- 定义一个名叫hello的插件任务</span>
<span class="n">task</span><span class="p">(</span><span class="s2">"hello"</span><span class="p">)</span>

    <span class="c1">-- 设置类型为插件</span>
    <span class="n">set_category</span><span class="p">(</span><span class="s2">"plugin"</span><span class="p">)</span>

    <span class="c1">-- 插件运行的入口</span>
    <span class="n">on_run</span><span class="p">(</span><span class="k">function</span> <span class="p">()</span>

        <span class="c1">-- 显示hello xmake!</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">"hello xmake!"</span><span class="p">)</span>

    <span class="k">end</span><span class="p">)</span>

    <span class="c1">-- 设置插件的命令行选项，这里没有任何参数选项，仅仅显示插件描述</span>
    <span class="n">set_menu</span> <span class="p">{</span>
                <span class="c1">-- usage</span>
                <span class="n">usage</span> <span class="o">=</span> <span class="s2">"xmake hello [options]"</span>

                <span class="c1">-- description</span>
            <span class="p">,</span>   <span class="n">description</span> <span class="o">=</span> <span class="s2">"Hello xmake!"</span>

                <span class="c1">-- options</span>
            <span class="p">,</span>   <span class="n">options</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="p">}</span> 
</code></pre>
</div>

<p>这个插件的文件结构如下：</p>

<div class="highlighter-rouge"><pre class="highlight"><code>hello
 - xmake.lua

</code></pre>
</div>

<p>现在一个最简单的插件写完了，那怎么让它被xmake检测到呢，有三种方式：</p>

<ol>
  <li>把 hello 这个文件夹放置在 xmake的插件安装目录 <code class="highlighter-rouge">xmake/plugins</code>，这个里面都是些内建的插件</li>
  <li>把 hello 文件夹放置在 <code class="highlighter-rouge">~/.xmake/plugins</code> 用户全局目录，这样对当前xmake 全局生效</li>
  <li>把 hello 文件夹放置在任意地方，通过在工程描述文件xmake.lua中调用<code class="highlighter-rouge">add_plugindirs("./hello")</code> 添加当前的工程的插件搜索目录，这样只对当前工程生效</li>
</ol>

<h4 id="运行插件">运行插件</h4>

<p>接下来，我们尝试运行下这个插件：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code>xmake hello
</code></pre>
</div>

<p>显示结果：</p>

<div class="highlighter-rouge"><pre class="highlight"><code>hello xmake!
</code></pre>
</div>

<p>最后我们还可以在target自定义的脚本中运行这个插件：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"demo"</span><span class="p">)</span>
    
    <span class="c1">-- 构建之后运行插件</span>
    <span class="n">after_build</span><span class="p">(</span><span class="k">function</span> <span class="p">(</span><span class="n">target</span><span class="p">)</span>
  
        <span class="c1">-- 导入task模块</span>
        <span class="n">import</span><span class="p">(</span><span class="s2">"core.project.task"</span><span class="p">)</span>

        <span class="c1">-- 运行插件任务</span>
        <span class="n">task</span><span class="p">.</span><span class="n">run</span><span class="p">(</span><span class="s2">"hello"</span><span class="p">)</span>
    <span class="k">end</span><span class="p">)</span>
</code></pre>
</div>

<h2 id="内置插件">内置插件</h2>

<h4 id="宏记录和回放">宏记录和回放</h4>

<h5 id="简介-1">简介</h5>

<p>我们可以通过这个插件，快速记录和回放我们平常频繁使用到的一些xmake操作，来简化我们日常的开发工作。</p>

<p>它提供了一些功能：</p>

<ul>
  <li>手动记录和回放多条执行过的xmake命令</li>
  <li>支持快速的匿名宏创建和回放</li>
  <li>支持命名宏的长久记录和重用</li>
  <li>支持宏脚本的批量导入和导出</li>
  <li>支持宏脚本的删除、显示等管理功能</li>
  <li>支持自定义高级宏脚本，以及参数配置</li>
</ul>

<h5 id="记录操作">记录操作</h5>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="ni"># </span><span class="nc">开始记录宏</span><span class="kv">
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> macro --begin
</span>
<span class="ni"># </span><span class="nc">执行一些xmake命令</span><span class="kv">
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f -p android --ndk=/xxx/ndk -a armv7-a
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> p
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f -p mingw --sdk=/mingwsdk
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> p
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f -p linux --sdk=/toolsdk --toolchains=/xxxx/bin
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> p
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f -p iphoneos -a armv7
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> p
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f -p iphoneos -a arm64
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> p
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f -p iphoneos -a armv7s
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> p
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f -p iphoneos -a i386
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> p
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f -p iphoneos -a x86_64
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> p
</span>
<span class="ni"># </span><span class="nc">结束宏记录，这里不设置宏名字，所以记录的是一个匿名宏</span><span class="kv">
</span>xmake macro --end 
</code></pre>
</div>

<h5 id="回放">回放</h5>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="ni"># </span><span class="nc">回放一个匿名宏</span><span class="kv">
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> macro .
</span></code></pre>
</div>

<h5 id="命名宏">命名宏</h5>

<p>匿名宏的好处就是快速记录，快速回放，如果需要长久保存，就需要给宏取个名字。</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> macro --begin
</span><span class="w">$ </span><span class="nc">...</span><span class="kv">
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> macro --end macroname
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> macro macroname
</span></code></pre>
</div>

<h5 id="导入导出宏">导入导出宏</h5>

<p>导入指定的宏脚本或者宏目录：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> macro --import=/xxx/macro.lua macroname
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> macro --import=/xxx/macrodir
</span></code></pre>
</div>

<p>导出指定的宏到脚本或者目录：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> macro --export=/xxx/macro.lua macroname
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> macro --export=/xxx/macrodir
</span></code></pre>
</div>

<h5 id="列举显示宏">列举显示宏</h5>

<p>列举所有<code class="highlighter-rouge">xmake</code>内置的宏脚本：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> macro --list
</span></code></pre>
</div>

<p>显示指定的宏脚本内容：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> macro --show macroname
</span></code></pre>
</div>

<h5 id="自定义宏脚本">自定义宏脚本</h5>

<p>我们也可以自己编写个宏脚本 <code class="highlighter-rouge">macro.lua</code> 然后导入到xmake中去。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="k">function</span> <span class="nf">main</span><span class="p">()</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake f -p android --ndk=/xxx/ndk -a armv7-a"</span><span class="p">)</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake p"</span><span class="p">)</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake f -p mingw --sdk=/mingwsdk"</span><span class="p">)</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake p"</span><span class="p">)</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake f -p linux --sdk=/toolsdk --toolchains=/xxxx/bin"</span><span class="p">)</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake p"</span><span class="p">)</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake f -p iphoneos -a armv7"</span><span class="p">)</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake p"</span><span class="p">)</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake f -p iphoneos -a arm64"</span><span class="p">)</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake p"</span><span class="p">)</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake f -p iphoneos -a armv7s"</span><span class="p">)</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake p"</span><span class="p">)</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake f -p iphoneos -a i386"</span><span class="p">)</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake p"</span><span class="p">)</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake f -p iphoneos -a x86_64"</span><span class="p">)</span>
    <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake p"</span><span class="p">)</span>  
<span class="k">end</span>
</code></pre>
</div>

<p>导入到xmake，并且定义宏名字：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> macro --import=/xxx/macro.lua [macroname]
</span></code></pre>
</div>

<p>回放这个宏脚本：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> macro [.|macroname]
</span></code></pre>
</div>

<h5 id="内置的宏脚本">内置的宏脚本</h5>

<p>XMake 提供了一些内置的宏脚本，来简化我们的日常开发工作。</p>

<p>例如，我们可以使用 <code class="highlighter-rouge">package</code> 宏来对<code class="highlighter-rouge">iphoneos</code>平台的所有架构，一次性批量构建和打包：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> macro package -p iphoneos 
</span></code></pre>
</div>

<h5 id="高级的宏脚本编写">高级的宏脚本编写</h5>

<p>以上面提到的<code class="highlighter-rouge">package</code>宏为例，我们看下其具体代码，里面通过<code class="highlighter-rouge">import</code>导入一些扩展模块，实现了复杂的脚本操作。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="c1">-- imports</span>
<span class="n">import</span><span class="p">(</span><span class="s2">"core.base.option"</span><span class="p">)</span>
<span class="n">import</span><span class="p">(</span><span class="s2">"core.project.config"</span><span class="p">)</span>
<span class="n">import</span><span class="p">(</span><span class="s2">"core.project.project"</span><span class="p">)</span>
<span class="n">import</span><span class="p">(</span><span class="s2">"core.platform.platform"</span><span class="p">)</span>

<span class="c1">-- the options</span>
<span class="kd">local</span> <span class="n">options</span> <span class="o">=</span>
<span class="p">{</span>
    <span class="p">{</span><span class="s1">'p'</span><span class="p">,</span> <span class="s2">"plat"</span><span class="p">,</span>       <span class="s2">"kv"</span><span class="p">,</span>  <span class="n">os</span><span class="p">.</span><span class="n">host</span><span class="p">(),</span>   <span class="s2">"Set the platform."</span>                                    <span class="p">}</span>
<span class="p">,</span>   <span class="p">{</span><span class="s1">'f'</span><span class="p">,</span> <span class="s2">"config"</span><span class="p">,</span>     <span class="s2">"kv"</span><span class="p">,</span>  <span class="kc">nil</span><span class="p">,</span>         <span class="s2">"Pass the config arguments to \"</span><span class="n">xmake</span> <span class="n">config</span><span class="err">\</span><span class="s2">" .."</span>     <span class="p">}</span>
<span class="p">,</span>   <span class="p">{</span><span class="s1">'o'</span><span class="p">,</span> <span class="s2">"outputdir"</span><span class="p">,</span>  <span class="s2">"kv"</span><span class="p">,</span>  <span class="kc">nil</span><span class="p">,</span>         <span class="s2">"Set the output directory of the package."</span>             <span class="p">}</span>
<span class="p">}</span>

<span class="c1">-- package all</span>
<span class="c1">--</span>
<span class="c1">-- .e.g</span>
<span class="c1">-- xmake m package </span>
<span class="c1">-- xmake m package -f "-m debug"</span>
<span class="c1">-- xmake m package -p linux</span>
<span class="c1">-- xmake m package -p iphoneos -f "-m debug --xxx ..." -o /tmp/xxx</span>
<span class="c1">-- xmake m package -f \"--mode=debug\"</span>
<span class="c1">--</span>
<span class="k">function</span> <span class="nf">main</span><span class="p">(</span><span class="n">argv</span><span class="p">)</span>

    <span class="c1">-- parse arguments</span>
    <span class="kd">local</span> <span class="n">args</span> <span class="o">=</span> <span class="n">option</span><span class="p">.</span><span class="n">parse</span><span class="p">(</span><span class="n">argv</span><span class="p">,</span> <span class="n">options</span><span class="p">,</span> <span class="s2">"Package all architectures for the given the platform."</span>
                                           <span class="p">,</span> <span class="s2">""</span>
                                           <span class="p">,</span> <span class="s2">"Usage: xmake macro package [options]"</span><span class="p">)</span>

    <span class="c1">-- package all archs</span>
    <span class="kd">local</span> <span class="n">plat</span> <span class="o">=</span> <span class="n">args</span><span class="p">.</span><span class="n">plat</span>
    <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">arch</span> <span class="k">in</span> <span class="nb">ipairs</span><span class="p">(</span><span class="n">platform</span><span class="p">.</span><span class="n">archs</span><span class="p">(</span><span class="n">plat</span><span class="p">))</span> <span class="k">do</span>

        <span class="c1">-- config it</span>
        <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake f -p %s -a %s %s -c %s"</span><span class="p">,</span> <span class="n">plat</span><span class="p">,</span> <span class="n">arch</span><span class="p">,</span> <span class="n">args</span><span class="p">.</span><span class="n">config</span> <span class="ow">or</span> <span class="s2">""</span><span class="p">,</span> <span class="n">ifelse</span><span class="p">(</span><span class="n">option</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"verbose"</span><span class="p">),</span> <span class="s2">"-v"</span><span class="p">,</span> <span class="s2">""</span><span class="p">))</span>

        <span class="c1">-- package it</span>
        <span class="k">if</span> <span class="n">args</span><span class="p">.</span><span class="n">outputdir</span> <span class="k">then</span>
            <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake p -o %s %s"</span><span class="p">,</span> <span class="n">args</span><span class="p">.</span><span class="n">outputdir</span><span class="p">,</span> <span class="n">ifelse</span><span class="p">(</span><span class="n">option</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"verbose"</span><span class="p">),</span> <span class="s2">"-v"</span><span class="p">,</span> <span class="s2">""</span><span class="p">))</span>
        <span class="k">else</span>
            <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"xmake p %s"</span><span class="p">,</span> <span class="n">ifelse</span><span class="p">(</span><span class="n">option</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"verbose"</span><span class="p">),</span> <span class="s2">"-v"</span><span class="p">,</span> <span class="s2">""</span><span class="p">))</span>
        <span class="k">end</span>
    <span class="k">end</span>

    <span class="c1">-- package universal for iphoneos, watchos ...</span>
    <span class="k">if</span> <span class="n">plat</span> <span class="o">==</span> <span class="s2">"iphoneos"</span> <span class="ow">or</span> <span class="n">plat</span> <span class="o">==</span> <span class="s2">"watchos"</span> <span class="k">then</span>

        <span class="c1">-- load configure</span>
        <span class="n">config</span><span class="p">.</span><span class="n">load</span><span class="p">()</span>

        <span class="c1">-- load project</span>
        <span class="n">project</span><span class="p">.</span><span class="n">load</span><span class="p">()</span>

        <span class="c1">-- enter the project directory</span>
        <span class="n">os</span><span class="p">.</span><span class="n">cd</span><span class="p">(</span><span class="n">project</span><span class="p">.</span><span class="n">directory</span><span class="p">())</span>

        <span class="c1">-- the outputdir directory</span>
        <span class="kd">local</span> <span class="n">outputdir</span> <span class="o">=</span> <span class="n">args</span><span class="p">.</span><span class="n">outputdir</span> <span class="ow">or</span> <span class="n">config</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"buildir"</span><span class="p">)</span>

        <span class="c1">-- package all targets</span>
        <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">target</span> <span class="k">in</span> <span class="nb">pairs</span><span class="p">(</span><span class="n">project</span><span class="p">.</span><span class="n">targets</span><span class="p">())</span> <span class="k">do</span>

            <span class="c1">-- get all modes</span>
            <span class="kd">local</span> <span class="n">modedirs</span> <span class="o">=</span> <span class="n">os</span><span class="p">.</span><span class="n">match</span><span class="p">(</span><span class="n">format</span><span class="p">(</span><span class="s2">"%s/%s.pkg/lib/*"</span><span class="p">,</span> <span class="n">outputdir</span><span class="p">,</span> <span class="n">target</span><span class="p">:</span><span class="n">name</span><span class="p">()),</span> <span class="kc">true</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">modedir</span> <span class="k">in</span> <span class="nb">ipairs</span><span class="p">(</span><span class="n">modedirs</span><span class="p">)</span> <span class="k">do</span>
                
                <span class="c1">-- get mode</span>
                <span class="kd">local</span> <span class="n">mode</span> <span class="o">=</span> <span class="n">path</span><span class="p">.</span><span class="n">basename</span><span class="p">(</span><span class="n">modedir</span><span class="p">)</span>

                <span class="c1">-- make lipo arguments</span>
                <span class="kd">local</span> <span class="n">lipoargs</span> <span class="o">=</span> <span class="kc">nil</span>
                <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">arch</span> <span class="k">in</span> <span class="nb">ipairs</span><span class="p">(</span><span class="n">platform</span><span class="p">.</span><span class="n">archs</span><span class="p">(</span><span class="n">plat</span><span class="p">))</span> <span class="k">do</span>
                    <span class="kd">local</span> <span class="n">archfile</span> <span class="o">=</span> <span class="n">format</span><span class="p">(</span><span class="s2">"%s/%s.pkg/lib/%s/%s/%s/%s"</span><span class="p">,</span> <span class="n">outputdir</span><span class="p">,</span> <span class="n">target</span><span class="p">:</span><span class="n">name</span><span class="p">(),</span> <span class="n">mode</span><span class="p">,</span> <span class="n">plat</span><span class="p">,</span> <span class="n">arch</span><span class="p">,</span> <span class="n">path</span><span class="p">.</span><span class="n">filename</span><span class="p">(</span><span class="n">target</span><span class="p">:</span><span class="n">targetfile</span><span class="p">()))</span> 
                    <span class="k">if</span> <span class="n">os</span><span class="p">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">archfile</span><span class="p">)</span> <span class="k">then</span>
                        <span class="n">lipoargs</span> <span class="o">=</span> <span class="n">format</span><span class="p">(</span><span class="s2">"%s -arch %s %s"</span><span class="p">,</span> <span class="n">lipoargs</span> <span class="ow">or</span> <span class="s2">""</span><span class="p">,</span> <span class="n">arch</span><span class="p">,</span> <span class="n">archfile</span><span class="p">)</span> 
                    <span class="k">end</span>
                <span class="k">end</span>
                <span class="k">if</span> <span class="n">lipoargs</span> <span class="k">then</span>

                    <span class="c1">-- make full lipo arguments</span>
                    <span class="n">lipoargs</span> <span class="o">=</span> <span class="n">format</span><span class="p">(</span><span class="s2">"-create %s -output %s/%s.pkg/lib/%s/%s/universal/%s"</span><span class="p">,</span> <span class="n">lipoargs</span><span class="p">,</span> <span class="n">outputdir</span><span class="p">,</span> <span class="n">target</span><span class="p">:</span><span class="n">name</span><span class="p">(),</span> <span class="n">mode</span><span class="p">,</span> <span class="n">plat</span><span class="p">,</span> <span class="n">path</span><span class="p">.</span><span class="n">filename</span><span class="p">(</span><span class="n">target</span><span class="p">:</span><span class="n">targetfile</span><span class="p">()))</span>

                    <span class="c1">-- make universal directory</span>
                    <span class="n">os</span><span class="p">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">format</span><span class="p">(</span><span class="s2">"%s/%s.pkg/lib/%s/%s/universal"</span><span class="p">,</span> <span class="n">outputdir</span><span class="p">,</span> <span class="n">target</span><span class="p">:</span><span class="n">name</span><span class="p">(),</span> <span class="n">mode</span><span class="p">,</span> <span class="n">plat</span><span class="p">))</span>

                    <span class="c1">-- package all archs</span>
                    <span class="n">os</span><span class="p">.</span><span class="n">execv</span><span class="p">(</span><span class="s2">"xmake"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"l"</span><span class="p">,</span> <span class="s2">"lipo"</span><span class="p">,</span> <span class="n">lipoargs</span><span class="p">})</span>
                <span class="k">end</span>
            <span class="k">end</span>
        <span class="k">end</span>
    <span class="k">end</span>
<span class="k">end</span>
</code></pre>
</div>

<p class="tip">
    如果你想要获取更多宏参数选项信息，请运行： `xmake macro --help`
</p>

<h4 id="运行自定义lua脚本">运行自定义lua脚本</h4>

<p>这个跟宏脚本类似，只是省去了导入导出操作，直接指定lua脚本来加载运行，这对于想要快速测试一些接口模块，验证自己的某些思路，都是一个不错的方式。</p>

<h5 id="运行指定的脚本文件">运行指定的脚本文件</h5>

<p>我们先写个简单的lua脚本：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="k">function</span> <span class="nf">main</span><span class="p">()</span>
    <span class="nb">print</span><span class="p">(</span><span class="s2">"hello xmake!"</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
</div>

<p>然后直接运行它就行了：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> lua /tmp/test.lua
</span></code></pre>
</div>

<p class="tip">
    当然，你也可以像宏脚本那样，使用`import`接口导入扩展模块，实现复杂的功能。
</p>

<h5 id="运行内置的脚本命令">运行内置的脚本命令</h5>

<p>你可以运行 <code class="highlighter-rouge">xmake lua -l</code> 来列举所有内置的脚本名，例如：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> lua -l
</span>scripts:
    cat
    cp
    echo
    versioninfo
    ...
</code></pre>
</div>

<p>并且运行它们：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> lua cat ~/file.txt
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> lua echo "hello xmake"
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> lua cp /tmp/file /tmp/file2
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> lua versioninfo
</span></code></pre>
</div>

<h5 id="运行交互命令-repl">运行交互命令 (REPL)</h5>

<p>有时候在交互模式下，运行命令更加的方便测试和验证一些模块和api，也更加的灵活，不需要再去额外写一个脚本文件来加载。</p>

<p>我们先看下，如何进入交互模式：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="ni"># </span><span class="nc">不带任何参数执行，就可以进入</span><span class="kv">
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> lua
</span>&gt;

<span class="ni"># </span><span class="nc">进行表达式计算</span><span class="kv">
</span>&gt; 1 + 2
3

<span class="ni"># </span><span class="nc">赋值和打印变量值</span><span class="kv">
</span>&gt; a = 1
&gt; a
1

<span class="ni"># </span><span class="nc">多行输入和执行</span><span class="kv">
</span>&gt; for _, v in pairs({1, 2, 3}) do
&gt;&gt; print(v)
&gt;&gt; end
1
2
3
</code></pre>
</div>

<p>我们也能够通过 <code class="highlighter-rouge">import</code> 来导入扩展模块：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code>&gt; task = import("core.project.task")
&gt; task.run("hello")
hello xmake!
</code></pre>
</div>

<p>如果要中途取消多行输入，只需要输入字符：<code class="highlighter-rouge">q</code> 就行了</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code>&gt; for _, v in ipairs({1, 2}) do
&gt;&gt; print(v)
&gt;&gt; q             &lt;--  取消多行输入，清空先前的输入数据
&gt; 1 + 2
3
</code></pre>
</div>

<h4 id="生成ide工程文件">生成IDE工程文件</h4>

<h5 id="简介-2">简介</h5>

<p>XMake跟<code class="highlighter-rouge">cmake</code>, <code class="highlighter-rouge">premake</code>等其他一些构建工具的区别在于：</p>

<p class="warning">
`xmake`默认是直接构建运行的，生成第三方的IDE的工程文件仅仅作为`插件`来提供。
</p>

<p>这样做的一个好处是：插件更加容易扩展，维护也更加独立和方便。</p>

<h5 id="生成makefile">生成Makefile</h5>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> project -k makefile
</span></code></pre>
</div>

<h5 id="生成compiler_commands">生成compiler_commands</h5>

<p>导出每个源文件的编译信息，生成基于clang的编译数据库文件，json格式，可用于跟ide，编辑器，静态分析工具进行交互。</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> project -k compile_commands
</span></code></pre>
</div>

<p>输出的内容格式如下：</p>

<div class="highlighter-rouge"><pre class="highlight"><code>[
  { "directory": "/home/user/llvm/build",
    "command": "/usr/bin/clang++ -Irelative -DSOMEDEF=\"With spaces, quotes and \\-es.\" -c -o file.o file.cc",
    "file": "file.cc" },
  ...
]

</code></pre>
</div>

<p>对于<code class="highlighter-rouge">compile_commands</code>的详细说明见：<a href="#https://clang.llvm.org/docs/JSONCompilationDatabase.html">JSONCompilationDatabase</a></p>

<h5 id="生成visualstudio工程">生成VisualStudio工程</h5>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> project -k [vs2008|vs2013|vs2015|..]
</span></code></pre>
</div>

<p>v2.1.2以上版本，增强了vs201x版本工程的生成，支持多模式+多架构生成，生成的时候只需要指定：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> project -k vs2017 -m "debug,release"
</span></code></pre>
</div>

<p>生成后的工程文件，同时支持<code class="highlighter-rouge">debug|x86</code>, <code class="highlighter-rouge">debug|x64</code>, <code class="highlighter-rouge">release|x86</code>, <code class="highlighter-rouge">release|x64</code>四种配置模式。</p>

<p>如果不想每次生成的时候，指定模式，可以把模式配置加到<code class="highlighter-rouge">xmake.lua</code>的中，例如：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="c1">-- 配置当前的工程，支持哪些编译模式</span>
<span class="n">set_modes</span><span class="p">(</span><span class="s2">"debug"</span><span class="p">,</span> <span class="s2">"release"</span><span class="p">)</span>
</code></pre>
</div>

<p>具体<code class="highlighter-rouge">set_modes</code>的使用，可以参考对应的接口手册文档。</p>

<h4 id="生成doxygen文档">生成doxygen文档</h4>

<p>请先确保本机已安装<code class="highlighter-rouge">doxygen</code>工具，然后在工程目录下运行：</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> doxygen
</span></code></pre>
</div>

<h2 id="更多插件">更多插件</h2>

<p>请到插件仓库进行下载安装: <a href="https://github.com/xmake-io/xmake-plugins">xmake-plugins</a>.</p>

<h4 id="从app生成ipa包">从app生成ipa包</h4>

<p>这仅仅是一个小插件，ios开发的同学，可能会用的到。</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> app2ipa --icon=/xxx.png /xxx/ios.app -o /xxx.ios.ipa
</span></code></pre>
</div>

        </article>
        <hr>

        <!-- baidu ads -->
        

        <!-- reward -->
        <div style="text-align: center;">
            <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
              <span>赏</span>
            </button>
            <div id="QR" style="display: none;">
                <div id="wechat" style="display: inline-block">
                  <img id="wechat_qr" src="/static/img/weixin.png" alt="WeChat Pay"/>
                  <p>微信打赏</p>
                </div>
                <div id="alipay" style="display: inline-block">
                  <img id="alipay_qr" src="/static/img/alipay.png" alt="Alipay"/>
                  <p>支付宝打赏</p>
                </div>
            </div>
        </div>

        
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
                    
                    <h2 id="english">English</h2>
                    <ul>
                    
                    <li class="relatedPost">
                        <a href="/docs/xmake/plugins/">Plugin Development
                        
                        </a>
                    </li>
                    
                    
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
        
            </ul>
        

        
        
            
        
            
            
            
                
                    
                        
                        <h2 id="similar_posts">相关文章</h2>
                        <ul>
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/12/17/xmake-update-v2.6.2/">xmake v2.6.2 发布，新增 Linux 内核驱动模块构建支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/12/03/xmake-update-v2.6.1/">xmake v2.6.1 发布，使用 Lua5.4 运行时，Rust 和 C++ 混合编译支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/10/30/xmake-update-v2.5.9/">xmake v2.5.9 发布，改进 C++20 模块，并支持 Nim, Keil MDK 和 Unity Build
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/10/08/xmake-update-v2.5.8/">xmake v2.5.8 发布，新增 Pascal/Swig 程序和 Lua53 运行时支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/08/29/xmake-update-v2.5.7/">xmake v2.5.7 发布，包依赖锁定和 Vala/Metal 语言编译支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
            
        
        
            </ul>
        

        <div class="post-recent">
    <div class="pre">

        

        

        
        
        

        

        

        
        
        <p><strong>上一篇</strong> <a href="/cn/docs/xmake/manual/">接口手册</a></p>
        
    </div>

    <div class="nex">

        

        

        
        
        

        

        

        
        
        <p><strong>下一篇</strong> <a href="/cn/2016/01/30/welcome/">欢迎来到TBOOX开源项目!</a></p>
        
    </div>
</div>


        <h2 id="comments">评论</h2>
        






<div id="gitalk-container"></div>
<link rel="stylesheet" href="/css/gitalk.css">
<script src="/js/gitalk.min.js"></script>

<script>
const gitalk = new Gitalk({
  clientID: '73946dc1d9e2276ad0da',
  clientSecret: '12a3cb94361ba3ebc6ecb68cf80d592bfaa8106d',
  repo: 'tboox.github.io',
  owner: 'waruqi',
  admin: ['waruqi'],
  id: location.pathname,       
  language: 'zh-CN',
  distractionFreeMode: false  
})

gitalk.render('gitalk-container')
</script>





    </div>
    <button class="anchor"><i class="fa fa-anchor"></i></button>
    <div class="right">
        <div class="wrap">

            <!-- codefund ads -->
            

            <!-- Content -->
            <div class="side content">
                <div>
                    内容
                </div>
                <ul id="content-side" class="content-ul">
                    <li><a href="#english">English</a></li>
                    <li><a href="#similar_posts">相关文章</a></li>
                    <li><a href="#comments">评论</a></li>
                </ul>
            </div>


            <!-- baidu ads -->
            
            
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    链接
                </div>
                <ul class="content-ul">
                  <li><a href="http://github.com/waruqi/tbox">tbox</a></li>
                  <li><a href="http://www.xmake.io">xmake</a></li>
                  <li><a href="https://github.com/waruqi">github</a></li>
                </ul>
            </div> 

            <!-- xmake courses -->
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    xmake 入门课程
                </div>
                <a href="https://xmake.io/#/zh-cn/about/course" target="_blank">
                <img src="/static/img/xmake-course.png" alt="course" width="256" height="193">
                </a>
            </div>

            <!-- qqgroup -->
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    技术交流群（QQ）
                </div>
                <img src="/static/img/qqgroup.png" alt="qqgroup" width="256" height="284">
            </div> 

            <!-- google ads -->
            

            <!-- baidu ads -->
            

        </div>
    </div>

    <!-- baidu ads -->
    
</div>
<script>
/**
 * target _blank
 */
(function() {
    var aTags = document.querySelectorAll('article a:not([id])')
    for (var i = 0; i < aTags.length; i++) {
        aTags[i].setAttribute('target', '_blank')
    }
}());
</script>
<script src="/js/pageContent.js " charset="utf-8"></script>



    <footer class="site-footer">
    <div class="wrapper">
        <p class="description">
             Copyright (c) 2016-2020 tboox.org 
        </p>
        <p class="contact">
            
            <a href="https://github.com/waruqi" title="GitHub"><i class="fa fa-github" aria-hidden="true"></i></a> 
             
            
            <a href="mailto:waruqi@gmail.com" title="email"><i class="fa fa-envelope-o" aria-hidden="true"></i></a> 
            
            
            <a href="https://twitter.com/waruqi" title="Twitter"><i class="fa fa-twitter" aria-hidden="true"></i></a> 
            
            <a href="/feed.xml" title="feed"><i class="fa fa-feed" aria-hidden="true"></i></a> 
        </p>
        <p class="power">
            <span>
                Site powered by <a href="https://jekyllrb.com/">Jekyll</a> & <a href="https://github.com/Gaohaoyang">HyG</a> & <a href="https://pages.github.com/">Github Pages</a>.
            </span>
        </p>
    </div>
</footer>

    <div class="back-to-top">
    <a href="#top" class="scroll">
        <i class="fa fa-arrow-up" aria-hidden="true"></i>
    </a>
</div>

    <script src=" /js/main.js " charset="utf-8"></script>
    <script src=" /js/scroll.min.js " charset="utf-8"></script>
  </body>

</html>
